package com.zhsj.OkeHomeConsumption.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhsj.OkeHomeConsumption.R;
import com.zhsj.OkeHomeConsumption.empty.BankMessage;

import java.util.List;

/**
 * Created by zwj on 2018/3/14.
 */

public class BankAdapter extends BaseAdapter {

    private Context context;
    private List<BankMessage> list;
    private LayoutInflater mLayoutInflater;

    public BankAdapter(Context context, List<BankMessage> walletList) {
        this.context = context;
        this.list = walletList;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.item_bank, null);
            viewHolder.bankname_text = (TextView) convertView.findViewById(R.id.bankname_text);
            viewHolder.bankno_text = (TextView) convertView.findViewById(R.id.bankno_text);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final BankMessage item = list.get(position);

        if (item != null) {
            viewHolder.bankname_text.setText(item.getBank_name());
            viewHolder.bankno_text.setText("**** **** **** " + item.getCard_no());
        }
        return convertView;
    }


    class ViewHolder {
        //银行名称
        private TextView bankname_text;
        //银行账户
        private TextView bankno_text;
    }
}